<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <div id="app">
        <cpn></cpn>
        <cpn></cpn>
        <cpn ref="aaa"></cpn>
        <button @click="btnclick">button</button>
    </div>
    <template id="cpn">
        <div>i am chideren</div>
    </template>
    <script src="../vue.js"></script>
    <script>
        const app = new Vue({
            el: '#app',
            methods: {
                btnclick() {
                    // this.$children[2].showMessage()
                    // console.log(this.$children[0].name);
                    console.log(this.$refs.aaa.name);
                }
            },
            components: {
                cpn: {
                    template: '#cpn',
                    methods: {
                        showMessage() {
                            console.log('this is from children');
                        }
                    },
                    data() {
                        return {
                            name: 'wyb'
                        }
                    }
                }
            }

        }) 
    </script>
</body>
</html>